<me:UIEKK x:Class="WPFExcelReport.TEKKOPF"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"  
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                     xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"  
                     xmlns:HR="clr-namespace:WPFExcelReport;assembly=THRSTAMM" 
                     xmlns:ZB="clr-namespace:WPFExcelReport;assembly=TVKZUAB"    
                     xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR"  
                    xmlns:EKD="clr-namespace:WPFExcelReport;assembly=TEKADR"  
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    x:Name="TV"
                    Loaded="Window_Loaded"
     >
    <me:UIEKK.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>
        <ucd:Divideby10  x:Key="d10"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter  x:Key="nbv"/>
        <ucd:NOTConverter x:Key="not"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIEKK.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"  >
            <StackPanel  VerticalAlignment="Top" Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource nbv}}">
                <WrapPanel   > 
                    <Grid Margin="10,0,0,0"  VerticalAlignment="Top" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24"
                            IsEnabled="{Binding IsCanNew,ElementName=TV}"
                            >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" IsEnabled="{Binding IsCanChg,ElementName=TV}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button  Click="EditCommand" Width="24" Height="20">
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                      IsEnabled="{Binding IsCanDelete,ElementName=TV}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" IsEnabled="{Binding IsCanInactive,ElementName=TV}" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Click="InactiveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/split.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <LS:TSLS02 Grid.Column="1" MinWidth="100" Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}"
                                   KEY="{Binding Path=LIEFNR,ElementName=TV}" 
                                  IsEdit="True"
                               /> 

                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=采购单}}"/>
                        <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"   IsAutoClear="True" 
                              CharacterCasing="Upper" Text="{Binding KRS,ElementName=TV}" Width="30" />
                        <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  IsAutoClear="True" 
                              Text="{Binding LFD,ElementName=TV}" KeyUp="Query_KeyUp" Width="90" />
                    </Grid>
                    <Grid Margin="10,0,0,0"  VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                            </Button.Background>
                        </Button>
                        <TextBlock Grid.Column="2" FontSize="16" Text="{Binding Source={Localization:Translate Word=查询}}"/>
                    </Grid>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top" Visibility="Collapsed" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button FontSize="16"  Content="{Binding Source={Localization:Translate Word=销售单}}" Click="QueryByVKAUF"/>
                        <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"   IsAutoClear="True" PRE="  " 
                              CharacterCasing="Upper" Text="{Binding VKKRS,ElementName=TV}" Width="30" />
                        <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6" PRE="000000"  
                              IsAutoClear="True" Text="{Binding VKLFD,ElementName=TV}" Width="90" />
                    </Grid>

                    <Grid Margin="10,0,0,0"  VerticalAlignment="Top"  Visibility="Collapsed">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"  Click="LinkedOrderCommand" Height="20" Margin="5,0,0,0" Width="24" >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/link.png" />
                            </Button.Background>
                        </Button>
                        <TextBlock Grid.Column="2" FontSize="16" Text="{Binding Source={Localization:Translate Word=管理销售}}"/>
                    </Grid>
                    <Button Width="80" Margin="10,0,0,0" VerticalAlignment="Top" 
                        Content="{Binding Source={Localization:Translate Word=完成采购单}}" Click="EKKConfonfirm"                          
                        IsEnabled="{Binding IsAUFConirmed,ElementName=TV,Converter={StaticResource not}}"/>
                    <Button Width="50" Margin="10,0,0,0" VerticalAlignment="Top" 
                        Content="{Binding Source={Localization:Translate Word=发票}}" Click="VRManagement"   />
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                      >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <DR:TDRAUFTR  Grid.Column="0" Name="cDR" DocType="{Binding PRTYPE,ElementName=TV}" PrintType="OpenExcel" />
                        <Button  Grid.Column="1"   Click="btnPrint_Click" Height="20" Margin="5,0,0,0" Width="Auto" Content="{Binding Source={Localization:Translate Word=打印采购单}}" />
                    </Grid>
                    <EKD:TEK08  Margin="10,0,0,0"  
                                  IsAuto="True" 
                                  VerticalAlignment="Top"
                                  ORDERNUM="{Binding AUF,ElementName=TV}"  
                                  IsEdit="{Binding IsEdit,ElementName=TV}"   
                             />
                </WrapPanel>
            </StackPanel>
            <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}">
                <Grid Margin="5,0,0,0" VerticalAlignment="Top" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=类型}}"/>
                    <SD:K8884  Grid.Column="2"
                               Name="cSD8884"
                                Width="100"
                                 IsEdit="True"
                                    KEY="{Binding AUFART,ElementName=TV}"
                                    ORDERNUM="{Binding AUFART,ElementName=TV }"/>

                </Grid>
                <LS:TSLS02 Grid.Column="1" Margin="10,0,0,0"
                                  IsEdit="True"
                                   KEY="{Binding Path=LIEFNR,ElementName=TV}"
                                 />
                <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/button_ok.png" />
                    </Button.Background>
                </Button>

            </WrapPanel>
        </StackPanel>
        <DataGrid  Grid.Row="1"  Grid.Column="0" 
                   Visibility="Collapsed"
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"     
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=EKPSA}" Header="{Binding Source={Localization:Translate Word=状态}}" Width="Auto"  />
                <DataGridTextColumn Header="" Binding="{Binding EKKAUFKRS}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=采购单}}" Binding="{Binding EKKAUFLFD}" Width="Auto"/>
                <DataGridTextColumn Header="" Binding="{Binding EKPAUFPOS}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=供应商}}" Binding="{Binding EKKLIEFNR}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=贸易条件}}" Binding="{Binding EKKKONDSL}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=物料}}" Binding="{Binding PART}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=色号}}" Binding="{Binding PFARBE}" Width="Auto"/>
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=数量}}" Binding="{Binding Path=EKPME1, Converter={StaticResource ResourceKey=d100}}" Width="Auto"/>
                <DataGridTextColumn Binding="{Binding Path=EKPME3,Converter={StaticResource d100}}" Header="{Binding Source={Localization:Translate Word=实收}}" Width="Auto" MinWidth="30" />
                <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=交期}}" Binding="{Binding EKPLTERM}" Width="Auto"/>
                <DataGridTextColumn Binding="{Binding Path=EKPWUTERM}" Header="{Binding Source={Localization:Translate Word=确认}}" Width="80" MinWidth="30" />
                <DataGridTextColumn Binding="{Binding Path=EKPGENDAT1}" Header="{Binding Source={Localization:Translate Word=船样}}" Width="80" MinWidth="30" />
                <DataGridTextColumn Binding="{Binding Path=EKPSACHB}" Header="{Binding Source={Localization:Translate Word=负责人}}" Width="Auto" MinWidth="30" />
            </DataGrid.Columns>
        </DataGrid  >
        <WrapPanel Grid.Row="2" Grid.Column="1" Visibility="Collapsed">
            <WrapPanel >
                <TextBlock Text="{Binding TKEY1}"  Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding SUM1,Converter={StaticResource d100}}" Foreground="Red" Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding TKEY2}"   Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding SUM2}" Foreground="Red" Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding TKEY3}"   Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding SUM3}" Foreground="Red" Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding TCOUNT1}"   Margin="10,0,0,0"></TextBlock>
                <TextBlock Text="{Binding Counts}" Foreground="Red" Margin="20,0,0,0"></TextBlock>
            </WrapPanel>
        </WrapPanel>
    </Grid>
</me:UIEKK>
